<?php
/**
 * Created by PhpStorm.
 * User: alexlz
 * Date: 10/2/14
 * Time: 9:43 AM
 */

namespace mysql;

use base\ITransaction;

if (!defined('NYMPH_ROOT')) {
  define('NYMPH_ROOT', dirname("../../../" . __FILE__));
  require(NYMPH_ROOT . '/local/loader/kernel/classes/URLClassLoader.php');
}

/**
 * The MySQLTransaction class(implements from ITransaction) provides methods
 * for executing transaction actions directly for MySQL
 */
class MySQLTransaction implements ITransaction {

  /**
   * (PHP 5)<br/>
   * Starts transaction.
   */
  static function startTransaction()
  {
    return mysql_query("BEGIN");
  }

  /**
   * (PHP 5)<br/>
   * Commits all changes transaction which were added after starting transaction.
   */
  static function commitTransaction()
  {
    return mysql_query("COMMIT");
  }

  /**
   * (PHP 5)<br/>
   * Discards all changes which were added after starting transaction.
   */
  static function rollbackTransaction()
  {
    return mysql_query("ROLLBACK");
  }
}